package org.coco.cloud.product.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.coco.cloud.product.bean.Product;
import org.coco.cloud.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author fengleifl-hzgs
 * @Date 2025/1/19
 * @since
 */
@RequestMapping("/api/product")
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("product/{id}")
    public Product getProduct(@PathVariable("id") Long productId, HttpServletRequest request) {
        String headerToken = request.getHeader("X-Token");
        System.out.println("productId: " + productId +" headerToken: "+headerToken);
        Product product = productService.getProduceById(productId);
        return product;
    }
}
